package com.kinyx.framework.db.sentence.res;

import org.junit.Test;

import com.kinyx.framework.db.sentence.CompareType;
import com.kinyx.framework.utils.KEnumUtils;

public class _Expression_COMPARE_TO_Tester_ extends SUPER {

	public void test(final String tableAlias, final int tableIdx, final Column column, final String columnName, final String fieldName, final String rightTableAlias, final int rightTableIdx, final Column rightColumn, final String rightColumnName, final String rightFieldName) {
		KEnumUtils.iterator(CompareType.class, e -> {
			final _Expression_COMPARE_TO expression = new _Expression_COMPARE_TO(column.idx(tableIdx), e, rightColumn.idx(rightTableIdx));

			final String sentence1 = columnName + " " + e.getValue() + " " + rightColumnName;
			final String sentence2 = fieldName + " " + e.getValue() + " " + rightFieldName;
			final String sentence3 = tableAlias + (tableIdx == 0 ? "" : tableIdx) + "." + columnName + " " + e.getValue() + " " + rightTableAlias + (rightTableIdx == 0 ? "" : rightTableIdx) + "." + rightColumnName;
			final String sentence4 = tableAlias + (tableIdx == 0 ? "" : tableIdx) + "." + fieldName + " " + e.getValue() + " " + rightTableAlias + (rightTableIdx == 0 ? "" : rightTableIdx) + "." + rightFieldName;

			this.test_getSentence(expression, //
					sentence1, //
					sentence2, //
					sentence3, //
					sentence4 //
			);
			this.test_toString(expression, //
					"SQL: [" + sentence1 + "]", //
					"HQL: [" + sentence2 + "]", //
					"SQL: [" + sentence3 + "]", //
					"HQL: [" + sentence4 + "]" //
			);
		});
	}

	@Test
	public void test() {
		this.list_tableIdx.forEach(tableIdx -> {
			this.list_column.forEach(column -> {
				this.list_tableIdx.forEach(tableIdx2 -> {
					this.list_column.forEach(column2 -> {
						this.test("demoEntity", tableIdx, column.column, column.columnName, column.fieldName, "demoEntity", tableIdx2, column2.column, column2.columnName, column2.fieldName);
					});
				});
			});
		});
	}

}
